from reportlab.lib.units import cm
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter
from gestion.ventas.models import Item	

def factura():
	nombre = "Gonzalo Almeida"
	domicilio = "pehuajo 1459"
	cuit = "20-31217752-9"
	fecha = "22/10/1984"
	ing_brutos = "234"
	remito = "1235"
	cant = "3"
	descripcion ="comida china"
	precio_unit = "23.3"
	precio_total = "72"
	in_line = Item.objects.all()

	page_size = (letter[0]/2.0,letter[1]/2.0)
	page_size = (15.5*cm,20*cm)
	fact = canvas.Canvas("Factura.pdf",pagesize=page_size)
	fact.drawString(11.2*cm,16*cm +cm*0.7, fecha)
	fact.drawString(3*cm,14*cm + 0.3*cm, nombre)
	fact.drawString(3*cm,13*cm + 0.6*cm, domicilio)
	fact.drawString(10.8*cm,12*cm + 0.6*cm, cuit)
	fact.drawString(11.8*cm,12*cm , ing_brutos)
	print "blaaaaaa"
	fact.drawString(11.5*cm,11*cm + 0.5*cm, remito)
	fact.circle(5.7*cm,12*cm+ 0.5*cm,0.07*cm,fill=1)
	y = 10.9*cm
	for item in in_line:
		fact.drawString(1.4*cm,y, str(item.cantidad))
		fact.drawString(3.4*cm,y, item.producto.nombre)
		fact.drawString(11.4*cm,y, str(item.precio_unitario))
		fact.drawString(13*cm,y, str(item.importe))
		y = y - 0.6*cm
	fact.showPage()
	fact.save()


factura()
